{include file="public_iframe:head"}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="row">
                        <div class="col-sm-3">
                        </div>
                        <form class="form-inline" action="" method="get">
                            <div class="col-sm-9">
                                <div class="input-group col-sm-6  pull-right">
                                    <select class="form-control m-b " style="width:49%; margin-right:1%;" name="parent_id" onchange="category(this)">
                                        <option value="0">请选择父分类</option>
                                        {volist name="industry_category" id="vo"}
                                            <option value="{$vo.id}" {if condition="$parent_id eq $vo.id"}selected = "selected"{/if}/>{$vo.name}</option>
                                        {/volist}
                                    </select>
                                    <select class="form-control m-b cid" style="width:49%; margin-right:1%;" name="cid">
                                        <option value="0">请选择子分类</option>
                                        {volist name="industry_category_nav" id="vo"}
                                            <option value="{$vo.id}" {if condition="$cid eq $vo.id"}selected = "selected"{/if}>{$vo.name}</option>
                                        {/volist}
                                    </select>
                                    <span class="input-group-btn">
                                      <button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
                                    </span>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <div class="col-sm-3">
                                <a class="btn btn-primary" href="{:url('Industry/add_lists')}">添加行业</a>
                            </div>
                            <thead>
                            <tr>
                                <th>行业名称</th>
                                <th>行业分类</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="industry" id="vo"}
                            <tr>
                                <td>{$vo.name}</td>
                                <td>{$vo.cateogry_name}</td>
                                <td><a data-toggle="modal" class="btn btn-primary" href="{:url('Industry/add_lists',['id'=>$vo.id])}">修改</a>
                                <a data-toggle="modal" class="btn btn-primary" href="{:url('Industry/lists_del',['id'=>$vo.id])}">删除</a></td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function category(obj){
        var val = $(obj).val();
        if(val != 0){
            var formData = new FormData();

            formData.append('parent_id',val);

            $.ajax({
                url:"{:url('Industry/select_catgory_result')}",
                type:'POST',
                data:formData,
                async:false,
                processData:false,
                contentType:false,
                success:function(result) {
                     if(result.msg.length != 0){
                        var html = '';
                        for (var i = 0; i < result.msg.length; i++) {
                            html +='<option value="'+result.msg[i].id+'">'+result.msg[i].name+'</option>';
                        }

                        $('.cid').append(html);
                     }

                }
            });
        }
    }

</script>
</html>
